import java.awt.*;
import java.awt.event.*;
//import javax.swing.*;

class CardLayoutEx extends Frame implements ActionListener
{
	Panel p = new Panel(); /*面板*/
	Button bf = new Button("第一个");
	Button bl = new Button("最后一个");
	Button bn = new Button("下一个");
	Button bp = new Button("上一个");
	Button bg = new Button("Go");

	TextField tf = new TextField();
	CardLayout cl = new CardLayout();
	CardLayoutEx() {
		this.setTitle("CardLayout 布局管理器");
		this.setLayout(null);
		this.add(p);
		p.setLayout(cl);
		for(int i=1; i<= 10; i++) {
			Button btemp = new Button("按键"+i);
			p.add(btemp,""+i);
		}

	p.setBounds(10,40,100,100);
	this.add(bf);
	bf.addActionListener(this);
	bf.setBounds(120,40,60,20);
	this.add(bl);
	bl.addActionListener(this);
	bl.setBounds(120,70,60,20);
	this.add(bn);
	bn.addActionListener(this);
	bn.setBounds(120,100,60,20);
	this.add(bp);
	bp.addActionListener(this);
	bp.setBounds(120,130,60,20);
	this.add(bg);
	bg.addActionListener(this);
	bg.setBounds(60,160,60,20);
	this.add(tf);
	tf.setBounds(20,160,40,20);
	this.setBounds(200,200,210,220);
	this.setVisible(true);
//	this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public void actionPerformed(java.awt.event.ActionEvent e)
{
	if(e.getSource()==bn)
	{
		cl.next(p);
	}

	if(e.getSource()==bp)
	{
		cl.previous(p);
	}

	if(e.getSource()==bf)
	{
		cl.first(p);
	}

	if(e.getSource()==bl)
	{
		cl.last(p);
	}

	if(e.getSource()==bg)
	{
		cl.show(p,tf.getText().trim());
		tf.setText("");
	}
}

	public static void main(String args[])
	{
		new CardLayoutEx();
	}
}
